home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / vgx3.zip / VGX.DOC < prev    next >
Text File  |  1993-01-06  |  15KB  |  353 lines

  1.                                VGX
  2.                                 
  3.                   A VGA Graphics file format for
  4.                  QuickBASIC and Professional BASIC
  5.                            Programmers
  6.  
  7.                      Version 3.0, January, 1993
  8.  
  9.  
  10.                            USER MANUAL
  11.  
  12.  
  13.  
  14. Speed, speed, speed is what we want when loading a graphics file. Second 
  15. only to speed is compressed file size.  Also desirable is ease of use.
  16.  
  17. Well, welcome to VGX!  You have received an efficient, fast, and compressed 
  18. VGA graphics file format for your BASIC programs that is remarkably easy to 
  19. use. It may also be the fastest VGA hi-res graphics file loader on the 
  20. market!
  21.  
  22.  
  23. First, let's get a few preliminaries behind us:
  24.  
  25. LICENSE AGREEMENT:
  26.  
  27. All files on the VGX distribution disk are (C) Copyright, 1990-93, Dwain 
  28. Goforth, Milestone Software, Arcata, California.  All rights reserved.
  29.  
  30. This software package (VGX30.ZIP and associated files) is for review 
  31. purposes only.  No license is granted for distribution of this software or 
  32. software created using the VGX object libraries.  The single exception to 
  33. this is that the original .ZIP distribution package may be distributed 
  34. provided no changes are made to any of the enclosed files.
  35.  
  36. The VGX package comes with three types of files, 1) compiled object code in 
  37. libraries (files with the .LIB extension), 2) executable files (PCX2VGX.EXE 
  38. and VGXGRAB.COM), and 3) text and BASIC source code files (with extensions 
  39. of .DOC and .BAS)
  40.  
  41. Upon registration, you will be licensed to distribute executable (.EXE and 
  42. .COM) programs of your own creation that use the VGX object modules.  No 
  43. royalties or copyright acknowledgement are required.  You will also be 
  44. licensed to distribute PCX2VGX.EXE and VGXGRAB.EXE as long as they have not 
  45. been modified in any way.
  46.  
  47. You are prohibited from distributing the VGX object files and their 
  48. associated libraries, or any library you make containing the VGX object 
  49. files, unless you are transfering this license in its entirety and removing 
  50. all VGX object files and any libraries containing them from your computer 
  51. system.
  52.  
  53.  
  54. WARRANTY:
  55.  
  56. Milestone Software makes no warranties or guarantees concerning use of this 
  57. shareware distribution package of VGX.  Registered users will be guaranteed 
  58. 100% satisfaction for one year following postmark of registration.
  59.  
  60.  
  61. REGISTERING THIS SOFTWARE:
  62.  
  63. By sending your registration fee for this software you will be licensed to 
  64. distribute executable programs created with the VGX object libraries, and 
  65. begin your one-year money-back warranty.
  66.  
  67. The registration cost is $20 (US funds only.)  Checks or money orders may be 
  68. sent to Dwain Goforth, Milestone Software, 1260 Sunset Ave., Arcata, 
  69. California, 95521. Canadian residents are encouraged to use Canadian Postal 
  70. Money Orders which save you money in bank fees. All other checks and money 
  71. orders must be drawn on a US bank.
  72.  
  73. Please note that this fee is modest considering the effort that has been put 
  74. into developing VGX. If you distribute executable files containing VGX or 
  75. object files (including libraries) other than this ZIP package you can 
  76. expect to fork over your profits to me, as well as punitive damages and 
  77. lawyer fees.
  78.  
  79.  
  80.                   ----------------------------------
  81.  
  82. FILES ON THE VGX DISK:
  83.  
  84. The following files are included on the VGX distribution disk: 
  85.  
  86.      VGX.DOC     -    This file, the VGX manual.
  87.      VGXSPEC.DOC -    Specifications of the VGX format.
  88.  
  89.      VGXN.LIB    -    Library for BASIC 7.0 using NEAR strings.
  90.      VGXF.LIB    -    Library for BASIC 7.0 using FAR strings.
  91.  
  92.      VGXF.QLB    -    BASIC 7.0 (QBX.EXE) quicklibrary (far
  93.                       strings.)
  94.  
  95.      PALCALLS.BAS  -  VGA palette routines.
  96.          
  97.      VGXTEST.BAS    -    BASIC source code to demonstrate VGX and
  98.                          palette calls.
  99.      VGXVIEW.BAS    -    BASIC source code to view VGX files.
  100.  
  101.      PCX2VGX.EXE    -    Program to convert PCX to VGX.
  102.   
  103.      VGXGRAB.COM    -    TSR (memory resident) program to capture
  104.                          VGA SCREEN 12 (640x480x16) to a VGX file.
  105.  
  106.                    ------------------------- 
  107.  
  108. INTRODUCTION - What is VGX? 
  109.  
  110. VGX is a new graphics file format for use by Microsoft PDS BASIC 7.x 
  111. programmers.  VGX supports ONLY the VGA 640x480 pixel 16-color graphics mode 
  112. (SCREEN 12), and because of this it is very fast.
  113.  
  114. If you've ever programmed VGA graphics files using the BASIC BSAVE/BLOAD 
  115. commands you know that even the least complex image requires 153k of disk 
  116. space in FOUR separate files.  Also, your palette is not saved.  While BLOAD 
  117. is fast, the file sizes, number of files and lack of palette are enough to 
  118. make one think twice before developing a VGA image program in BASIC. 
  119.  
  120.  
  121. HOW DOES VGX WORK?: 
  122.  
  123. VGX is similar to BLOAD/BSAVE in that images are stored in "banks" just like 
  124. the VGA video memory stores them.  Each bank represents one color (red, 
  125. blue, green and intensity) and each bit in the bank is either on or off and 
  126. represents each pixel.  A VGA 640x480 16-color screen uses 152k of video RAM 
  127. with each bank using 38k. 
  128.  
  129. VGX is similar to PCX in that it uses a "run-length" encoding scheme to 
  130. compress the data.  The PCX format compresses a screen one scan line at a 
  131. time (there are 480 scan lines in a VGA 640x480), while VGX compresses an 
  132. entire bank at a time.  When a run of the same byte pattern is encountered 
  133. in a color bank, VGX stores a count for them instead of the actual data. 
  134. Because banks are a series of 1's and 0's (on and off), the VGX compression 
  135. of an entire bank is usually quite efficient.  VGX switches banks four times 
  136. for each file, PCX switches banks four times for each scan line (1920 times 
  137. per file!) 
  138.  
  139. The VGA adapter stores the palette in 16 byte-triplets (one byte for each 
  140. color; 48 bytes total.)  VGX simply gets this data from the VGA BIOS and 
  141. adds it to the VGX file.  Included is a BASIC program, PALCALLS.BAS which 
  142. will demonstrate the BIOS palette calls, show how to "fade" the 48-byte 
  143. palette data, and also how to rotate the palette ("palette animation".)
  144.  
  145. The VGXSave routine works by moving a VGA bank into RAM, compressing the 
  146. data into an array and saving the compressed array as a temporary file.  
  147. This is repeated three times, then the temporary files are appended together 
  148. along with the palette information.  The temporary files are then erased. In 
  149. the unlikely event that your computer crashes during a VGXSave session, you 
  150. may find these temporary files on your directory (filename.VX1 to 
  151. filename.VX4). They can be erased.
  152.  
  153. Because VGXSave copies an image of a bank and allocates an array to hold the 
  154. compressed data, VGXSave needs 74k of available RAM to work. This RAM is 
  155. allocated at the beginning of each VGXSave call and released at the end of 
  156. each call.
  157.  
  158. VGXLoad works in an opposite manner to VGXSave; a 16k file-load buffer is 
  159. created as well as an 38k array to hold an uncompressed bank.  The 
  160. decompression algorithm works on one buffer's worth of data at a time, 
  161. filling the bank array.  When a bank is full, it is transfered to video RAM.  
  162. When a buffer is used up, another is gotten from the disk. Depending on 
  163. which option you choose to load a VGX image (fade-in, instant on, etc...), 
  164. the palette is processed before or after the actual load.
  165.  
  166. Because VGXLoad uses a 16k file buffer and a 38k bank array, VGXLoad 
  167. requires 54k of free RAM to work. This RAM is allocated at the start of each 
  168. VGXLoad call and released at the end.  The 16k buffer size was chosen as the 
  169. optimum in a tradeoff between loading speed and minimizing RAM use.  (An 
  170. earlier, pre-release version of VGXLoad had a self-allocating buffer of 2k 
  171. to 64k, but a "hard-wired" size proved to be faster.)
  172.  
  173. A number of algorithms were considered for the VGX compression. All of them 
  174. pose a tradeoff between compressed file size and speed of loading. And while 
  175. greater compression is obtainable, the vast superiority in speed of the 
  176. bank-load/run-length compression method left all other options in the dust.
  177.  
  178.              -----------------------------------------
  179.  
  180.                              USING VGX 
  181.  
  182. The VGX file format is very easy to use in your QuickBASIC programs.  You 
  183. simply add VGXx.LIB to your normal quicklibrary or use the supplied VGX 
  184. quicklibrary.  To create a stand-alone EXE file you link your program's 
  185. object file (created with BC) with VGXx.LIB. 
  186.  
  187. Once in QB, you simply CALL VGXSave (filname$) to save a file or CALL 
  188. VGXLoad (filname$, palflag%) to load a file. 
  189.  
  190. The most IMPORTANT thing to remember is filname$ MUST be just the first 
  191. eight letters of the filename (no extension.) Thus VGXSave("TEST") will work 
  192. fine, but VGXSave("TEST.VGX") will fail.
  193.  
  194. There is no error catching in VGXSave or VGXLoad. Every effort has been made 
  195. to return control to your calling program without crashing, but speed was 
  196. the overriding consideration. You will have to make sure that the syntax is 
  197. correct and valid filenames are used BEFORE call VGXLoad or VGXSave.
  198.  
  199. Libraries and Quicklibraries:
  200.  
  201. I have assumed that you already have your own personal library and 
  202. quicklibrary to which you will want to add VGXx.LIB.  To do so, type the 
  203. following at the DOS prompt:
  204.  
  205.      LIB yourname.lib +VGXx.LIB;
  206.      
  207.      LINK /q yourname.lib
  208.  
  209.      At the "Library" prompt type "QBXQLB"
  210.  
  211.      (Remember that you cannot make a near-string quicklibrary using 
  212.      VGXN.LIB, you have to use far strings in the QBX environment.)
  213.  
  214.  
  215. USING VGXSave:
  216.  
  217. Once in QB with a quicklibrary loaded containing VGX you may call VGXSave 
  218. and VGXLoad.  Prior to either call you MUST have entered VGA 640x480 
  219. 16-color graphics mode (SCREEN 12).  The syntax to call VGXSave is as 
  220. follows:
  221.  
  222.      CALL VGXSave(filnam$)
  223.  
  224. IMPORTANT!!! -->  Please note that "filnam$" DOES NOT include the extension, 
  225. thus to make a VGX file named "TEST.VGX" you CALL VGXSave("test"), the 
  226. extension will be added by VGXSave itself. 
  227.  
  228. Or...
  229.  
  230.      fil$="test"
  231.      CALL VGXSave(fil$)
  232.  
  233. You may also pass a path...
  234.  
  235.      fil$="C:\graphics\vgx\test"
  236.      CALL VGXSave(fil$)
  237.  
  238. To be on the safe side, your disk should have 153k of free space for the 
  239. maximum size of any potential VGX file.
  240.  
  241.  
  242. USING VGXLoad:
  243.  
  244. The VGXLoad routine has two parameters and is called as follows:
  245.  
  246.      CALL VGXLoad(Fil$, Flag%)
  247.  
  248. Again, DO NOT use a filename extension for Fil$.
  249.  
  250. Flag% is the parameter to choose one of five loading options, from "instant 
  251. on" to "fade-in".  
  252.  
  253. Flag% may range from 0 to 4.  The following table shows the action for the 
  254. Flag% options:
  255.  
  256.           action for          action for
  257.           current             screen being
  258. Flag%     screen              loaded
  259. ----------------------------------------------
  260.   0       no blank            bank load
  261.   1       blank to color 0    instant on
  262.   2       blank to color 0    fade in
  263.   3       fade out            instant on
  264.   4       fade out            fade in
  265.  
  266. If Flag is 0 then the current image gets replaced one bank at a time, as 
  267. soon as they are ready.  This is the fastest method to load a VGX screen.  
  268. It is very much like BLOADing.
  269.  
  270. If Flag is 1 or 2 then the current image is cleared to its current 
  271. background color (whatever color is assigned to attribute 0).  
  272.  
  273. If Flag is 3 or 4 then the palette for the current image is faded by 
  274. changing each attribute closer to attribute 0 (color 0) in a 64 count loop.
  275.  
  276. For the VGX screen you are loading "instant on" is where the file is loaded 
  277. into video RAM while all the colors are set to attribute zero and then DOS 
  278. is called to set the actual palette that was stored in the file.  This 
  279. method of setting the palette is very fast, much faster than using BASIC's 
  280. PALETTE statements.  See PALCALLS.BAS for the syntax used in VGXLoad.
  281.  
  282. "Fade in" makes a 64 count loop, gradually changing the colors from 
  283. attribute zero to their correct value.
  284.  
  285.  
  286. RUNNING PCX2VGX.EXE: 
  287.  
  288. If you have PCX files in 640x480 16-color format you can convert them to VGX 
  289. format using PCX2VGX.  PCX2VGX will convert the file, test load it, and even 
  290. test the gray-scale color balance (to see how your image will look on a 
  291. monochrome VGA display.) 
  292.  
  293. Please note that ONLY 640x480 16-color PCX files will convert correctly with 
  294. PCX2VGX.
  295.  
  296. Type `PCX2VGX filename' or 'PCX2EGX filename' at the DOS prompt, DO NOT 
  297. include any filename extension in `filename'. 
  298.  
  299.  
  300. RUNNING VGXGRAB.COM: 
  301.  
  302. VGXGRAB is a TSR (memory resident) program that will dump whatever is on 
  303. your VGA 640x480 16-color screen to a VGX file. Type VGXGRAB at the DOS 
  304. prompt and it will become resident. VGXGRAB will allocate approximately 80k 
  305. of RAM while resident. Some paint programs that require a full 640k to run 
  306. will not run when VGXGRAB is resident (you will get an "insufficient memory" 
  307. error) In that event, hopefully, your paint program will save to a PCX file 
  308. format which you can then convert to VGX using PCX2VGX. 
  309.  
  310. After VGXGRAB is resident, run whatever screen display program you wish to 
  311. capture from (VGXVIEW and VGXDEMO will work if you are just testing) and hit 
  312. the "hotkey" to save the image to a VGX format file.  The hotkey is 
  313. CTRL/ENTER (both the "Control" and "Enter" keys pressed at the same time.)  
  314. After the VGX file is saved you will hear a short beep and control will 
  315. return to your display program.
  316.  
  317. VGX files saved by VGXGRAB are named VGXxxx.VGX where xxx is a number, so 
  318. the first VGX file you create with VGXGRAB will be VGX1.VGX, the second, 
  319. VGX2.VGX, and so on.  If a VGX file with the same name already exists, that 
  320. number will be skipped, so, for example, if VGX1.VGX and VGX2.VGX already 
  321. exist on the default directory, then the fist file VGXGRAB will save is 
  322. VGX3.VGX, etc...
  323.  
  324. VGXGRAB cannot be removed from memory.  In other words you must reboot your 
  325. computer to remove them.  I have attempted to create removable TSR's (and 
  326. will continue to try) but so far they are quite buggy and I would rather be 
  327. safe than sorry.
  328.  
  329. Please remember that VGXGRAB is designed specifically for the 640x480x16 
  330. graphics modes.  Using it with other modes will give unpredictable results 
  331. (i.e., garbage.)
  332.  
  333.                           - - - - - - -
  334.  
  335. In summary, remember you have three ways to create a VGX file, 1) in QB (or 
  336. your compiled EXE) using VGXSave, 2) converting PCX files using PCX2VGX, and 
  337. 3) running the TSR program, VGXGRAB and capturing screens while in another 
  338. program. 
  339.  
  340. Please see "Optimizing VGX Files" in the VGXSPECS.DOC file for tips on how 
  341. to make your VGX files as small and efficient as possible.
  342.  
  343.                   --------------------------------
  344.  
  345. Thank you for trying VGX.  Please feel free to call or write with any 
  346. questions or comments.
  347.  
  348. Dwain Goforth 
  349. Milestone Software 
  350. 1260 Sunset Ave. 
  351. Arcata, CA 95521 USA 
  352. (707) 822-1291 
  353.